package com.aiyige.page.my.customer.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * Created by xiachao on 2018/3/27.
 */

public class CustomerScreenChildEntity implements Parcelable {

    String id;
    String name;
    boolean selected;

    public CustomerScreenChildEntity(){

    }
    public CustomerScreenChildEntity(Parcel in) {
        id = in.readString();
        name = in.readString();
        selected = in.readByte() != 0;
    }

    private CustomerScreenChildEntity(Builder builder) {
        setId(builder.id);
        setName(builder.name);
        setSelected(builder.selected);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(name);
        dest.writeByte((byte) (selected ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<CustomerScreenChildEntity> CREATOR = new Creator<CustomerScreenChildEntity>() {
        @Override
        public CustomerScreenChildEntity createFromParcel(Parcel in) {
            return new CustomerScreenChildEntity(in);
        }

        @Override
        public CustomerScreenChildEntity[] newArray(int size) {
            return new CustomerScreenChildEntity[size];
        }
    };

    public String getName() {
        return TextUtils.isEmpty(name)?"":name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public String getId() {
        return TextUtils.isEmpty(id)?"":id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public static final class Builder {
        private String id;
        private String name;
        private boolean selected;

        private Builder() {
        }

        public Builder id(String id) {
            this.id = id;
            return this;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder selected(boolean selected) {
            this.selected = selected;
            return this;
        }

        public CustomerScreenChildEntity build() {
            return new CustomerScreenChildEntity(this);
        }
    }
}
